<?php
class ModulePaymentVo extends SzAbstractMySqlVo
{

    private $userId;
    private $bonusMoney;
    private $purchasedMoney;
    private $commodityValue;

    /**
     * Initialize ModulePaymentVo.
     *
     * @param $userId
     * @param $bonusMoney
     * @param $purchasedMoney
     * @param $commodityValue
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return ModulePaymentVo
     */
    public function __construct($userId, $bonusMoney, $purchasedMoney, $commodityValue, $isInsert = false) {
        $this->userId = $userId;
        $this->bonusMoney = $bonusMoney;
        $this->purchasedMoney = $purchasedMoney;
        $this->commodityValue = $commodityValue;

        $this->isInsert = $isInsert;
        $this->voClassName = 'ModulePaymentVo';
        $this->ormName = 'ModulePayment';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'money' => $this->getMoney(),
            'bonusMoney' => $this->getBonusMoney(),
            'purchasedMoney' => $this->getPurchasedMoney(),
            'commodityValue' => $this->getCommodityValue(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'bonusMoney' => $this->getBonusMoney(),
            'purchasedMoney' => $this->getPurchasedMoney(),
            'commodityValue' => $this->getCommodityValue(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getUserId(),
            $this->getBonusMoney(),
            $this->getPurchasedMoney(),
            $this->getCommodityValue(),
        );
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(0, $this->userId);
        $this->userId = $val;
    }

    public function getBonusMoney()
    {
        return $this->bonusMoney;
    }

    public function setBonusMoney($val)
    {
        $this->saveColumnStatus(1, $this->bonusMoney);
        $this->bonusMoney = $val;
    }

    public function updateBonusMoney($val)
    {
        $this->saveColumnStatus(1, $this->bonusMoney);
        $this->bonusMoney += $val;
    }

    public function getPurchasedMoney()
    {
        return $this->purchasedMoney;
    }

    public function setPurchasedMoney($val)
    {
        $this->saveColumnStatus(2, $this->purchasedMoney);
        $this->purchasedMoney = $val;
    }

    public function updatePurchasedMoney($val)
    {
        $this->saveColumnStatus(2, $this->purchasedMoney);
        $this->purchasedMoney += $val;
    }

    public function getCommodityValue()
    {
        return $this->commodityValue;
    }

    public function setCommodityValue($val)
    {
        $this->saveColumnStatus(3, $this->commodityValue);
        $this->commodityValue = $val;
    }

    public function updateCommodityValue($val)
    {
        if (is_float($val)) {
            $val = floor($val);
        }

        $this->saveColumnStatus(3, $this->commodityValue);
        $this->commodityValue += $val;
    }

    /**
     * Get user money amount.
     * @return int $money
     */
    public function getMoney()
    {
        return $this->bonusMoney + $this->purchasedMoney;
    }
}